package de.tewdreyer.android.quaffed;

import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.FrameLayout;

import java.util.ArrayList;

public class ShowGraph extends Activity {

    ArrayList<String> keys;// = {"Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag","Sonntag"};
    ArrayList<Double> values;// = {120,100,90,150,200,250,10};

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.graph);

        // TODO cleanup
        keys = new ArrayList<String>();
        values = new ArrayList<Double>();
        MealOpenHelper db = new MealOpenHelper(getApplicationContext());
        db.insert("26.04.2011", 150);
        Cursor c = db.all(this);
        int idxDate = c.getColumnIndex("date");
        int idxVol = c.getColumnIndex("volume");
        c.moveToFirst();
        while (!c.isAfterLast()) {
            keys.add(c.getString(1));
            c.moveToNext();
            values.add(c.getDouble(1));
            c.moveToNext();
        }
        c.close();

        FrameLayout fl = (FrameLayout) findViewById(R.id.main_view);
        fl.addView(new BarChart(getApplicationContext(), keys, values));
    }
}